package com.ofhb.webapp.server.impl;

import java.util.List;

import javax.ejb.EJB;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.ofhb.bean.LookUpBean;
import com.ofhb.entities.CityEntity;
import com.ofhb.webapp.client.services.LookupService;
import com.ofhb.webapp.server.utils.OfhbUtils;
import com.ofhb.webapp.shared.dto.CityDTO;
import com.ofhb.webapp.shared.dto.LookupDataDTO;

public class LookupServiceImpl extends RemoteServiceServlet implements LookupService {

    private static final long serialVersionUID = -8241469346391765309L;

    @EJB
    LookUpBean lookUpBean;

	@Override
	public LookupDataDTO getLookupData() {
		LookupDataDTO lookupDataDTO = new LookupDataDTO();
		
		List<CityEntity> cityEntities = lookUpBean.getAllCityEntities();
		for (CityEntity cityEntity : cityEntities) {
			CityDTO cityDTO = new CityDTO();
			OfhbUtils.copyClass(cityEntity, cityDTO);
			lookupDataDTO.getListCityDTO().add(cityDTO);
		}
		
		return lookupDataDTO;
	}

}
